package com.jiali.backend.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Value("${file.upload-dir}")
    private String uploadDir;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 头像资源映射
        registry.addResourceHandler("/upload/avatar/**")
                .addResourceLocations("file:" + uploadDir.replace("\\", "/") + "/avatar/");
        // 员工照片资源映射（新增）
        registry.addResourceHandler("/upload/photo/staff/**")
                .addResourceLocations("file:" + uploadDir.replace("\\", "/") + "/photo/staff/");
    }
}